<template>
  <div class="popup-wrap" v-show="visible">
    <div class="popup-box">
      <header>
        <h2 class="title">{{title}}</h2>
        <a href="javascript:;" class="close" @click="close"></a>
      </header>
      <div class="content">
        <slot></slot>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'Popup',
  props: {
    title: {
      type: String,
      default: ''
    },
    visible: {
      type: Boolean,
      default: false
    }
  },
  methods: {
    close () {
      this.$emit('update:visible', false)
    }
  }
}
</script>

<style lang="scss" scoped>
.popup-wrap {
  @include wh(100vw, 100vh);
  background: rgba(0, 0, 0, 0.2);
  display: flex;
  position: fixed;
  top: 0;
  left: 0;
  .popup-box {
    @include flex(column);
    margin: auto;
    background: #fff;
    border-radius: 10px;
    padding: 20px;
    width: 80%;
    max-height: 70%;
    header {
      height: 25px;
      width: 100%;
      position: relative;
      .title {
        color: $base-color;
      }
      .close {
        @include wh(20px, 20px);
        background: #f00;
        position: absolute;
        right: 0;
        top: -60px;
      }
    }
  }
}
</style>
